function request(object, callback){
    let obj = {
        dataType: "json",
        contentType: "application/json",
    }
    let realObj = $.extend({}, obj, object)
    realObj.url = "/" + location.pathname.split("/")[1] + "/" + realObj.url;
    console.log("请求url ", realObj.url)
    $.ajax(realObj)
        .done(function(res){
            console.log("请求结果", res)
            if(res.code == 200){
                if(realObj.type != "GET")
                    layer.msg(res.message || "操作成功")
                if(callback)
                    callback(res)
            }else {
                layer.msg(res.message)
            }
        })
        .fail(function(){
            layer.msg("网络连接失败")
        })
}
function post(url, data, callback){
    request({
        type: "POST",
        data: data,
        url: url,
    }, callback);
}

function simplePost(url, callback) {
    request({
        type: "POST",
        url: url,
    }, callback);
}
function simplePut(url, callback){
    request({
        type: "PUT",
        url: url,
    }, callback);
}
function simpleDelete(url, callback){
    request({
        type: "DELETE",
        url: url,
    }, callback);
}
function simpleGet(url, callback){
    request({
        type: "GET",
        url: url,
    }, callback);
}
